﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using GMap.NET;
using GMap.NET.WindowsForms;
using GMap.NET.WindowsForms.Markers;
using GMap.NET.MapProviders;
using Business;
using System.Globalization;

namespace TimKiemDiaDiem
{
    public partial class HienThiMapForm : Form
    {
        public HienThiMapForm()
        {
            InitializeComponent();
            try
            {
                System.Net.IPHostEntry entry = System.Net.Dns.GetHostEntry("www.bing.com");
            }
            catch
            {
                mainMap.Manager.Mode = AccessMode.CacheOnly;
            }
            mainMap.Position = new PointLatLng(10.743343, 106.66941);
            mainMap.MinZoom = 8;
            mainMap.MaxZoom = 20;
            mainMap.Zoom = 15;
            top = new GMapOverlay(mainMap, "top");
            mainMap.Overlays.Add(top);
        }
        GMapMarker currentMarker;
        GMapOverlay top;
        DiaDiemDTO diaDiem;
        public DiaDiemDTO DiaDiem
        {
            set
            {
                diaDiem = value;
                top.Markers.Clear();                
                /*mainMap.Position = new PointLatLng(diaDiem.ViDo, diaDiem.KinhDo);*/
                mainMap.Position = new PointLatLng( diaDiem.KinhDo,diaDiem.ViDo);
                currentMarker = new GMapMarkerGoogleRed(mainMap.Position);
                top.Markers.Add(currentMarker);
            }
            get { return diaDiem; }
        }
        public GMapControl MainMap
        {
            get { return mainMap; }
            set { mainMap = value; }
        }
        
    }
}
